import Mock from 'mockjs'


// 模拟数据
export default {
    '/common/index get': {
        code: 200,
        msg: 'success',
        data: {
            appName: '官方客服系统',
            version: '1.0.0',
            // 使用 Mock.js 生成随机数据
            bannerList: Mock.mock({
                'list|3-5': [{
                    'id|+1': 1,
                    title: '@ctitle(5, 10)',
                    image: '@image(300x200, @color, @title)',
                    link: '@url'
                }]
            }).list,
        }
    },
    //登录接口模拟DEMO
    '/auth/login post@0': (options) => {
        const { username, password } = JSON.parse(options.body)
        if (username === 'admin' && password === '123456') {
            return {
                code: 200,
                msg: '登录成功',
                data: {
                    token: Mock.Random.string(32),
                    userInfo: {
                        id: Mock.Random.id(),
                        username: username,
                        name: '管理员',
                        avatar: Mock.Random.image('100x100', '#ffcc33', 'Avatar'),
                    }
                }
            }
        } else {
            return {
                code: 401,
                msg: '用户名或密码错误',
                data: {}
            }
        }
    }
}